// pages/api/shared-data.js
let sharedData = "Initial Data";

// src/app/api/shared-data/route.js
export async function GET(request) {
  return new Response(JSON.stringify({ data: sharedData }), {
    headers: { "Content-Type": "application/json" },
  });
}

export async function POST(request) {
  const body = await request.json();
  const sharedData = body.data;
  return new Response(JSON.stringify({ data: sharedData }), {
    headers: { "Content-Type": "application/json" },
  });
}

// export default function handler(req, res) {
//   if (req.method === "GET") {
//     res.status(200).json({ data: sharedData });
//   } else if (req.method === "POST") {
//     sharedData = req.body.data;
//     res.status(200).json({ data: sharedData });
//   } else {
//     res.status(405).end(); // Method Not Allowed
//   }
// }
